Divide a path on the extension separatorΒΆ
Divide a path on the extension separator.
import os.path
for path in ['test.txt',
'filename',
'/user/system/test.txt',
'/',
'']: print('"%s" :' % path, os.path.splitext(path))
Output:
"test.txt" : ('test', '.txt')
"filename" : ('filename', '')
"/user/system/test.txt" : ('/user/system/test', '.txt')
"/" : ('/', '')
"" : ('', '')